<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Submitting requests on behalf of other users | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'run-as-privilege.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/run-as-privilege.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/run-as-privilege.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/run-as-privilege.html" rel="nofollow" target="_blank">../en/run-as-privilege.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="secure-cluster.html">Secure a cluster</a></span>
»
<span class="breadcrumb-link"><a href="authorization.html">User authorization</a></span>
»
<span class="breadcrumb-node">Submitting requests on behalf of other users</span>
</div>
<div class="navheader">
<span class="prev">
<a href="field-and-document-access-control.html">« Setting up field and document level security</a>
</span>
<span class="next">
<a href="configuring-authorization-delegation.html">Configuring authorization delegation »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="run-as-privilege"></a>Submitting requests on behalf of other users<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/x-pack/docs/en/security/authorization/run-as-privilege.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>The Elasticsearch security features support a permission that enables an authenticated
user to submit
requests on behalf of other users. If your application already authenticates
users, you can use the <em>run as</em> mechanism to restrict data access according to
Elasticsearch permissions without having to re-authenticate each user through.</p>
<p>To "run as" (impersonate) another user, you must be able to retrieve the user from
the realm you use to authenticate. Both the internal <code class="literal">native</code> and <code class="literal">file</code> realms
support this out of the box. The LDAP realm must be configured to run in
<a class="xref" href="ldap-realm.html#ldap-realm-configuration" title="Configuring an LDAP realm"><em>user search</em> mode</a>. The Active Directory realm must be
<a class="xref" href="security-settings.html#ref-ad-settings" title="Active Directory realm settings">configured with a <code class="literal">bind_dn</code> and <code class="literal">secure_bind_password</code></a> to support
<em>run as</em>. The PKI, Kerberos, and SAML realms do not support <em>run as</em>.</p>
<p>To submit requests on behalf of other users, you need to have the <code class="literal">run_as</code>
permission. For example, the following role grants permission to submit request
on behalf of <code class="literal">jacknich</code> or <code class="literal">redeniro</code>:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">{
  "run_as" : [ "jacknich", "rdeniro" ]
}</pre>
</div>
<p>To submit a request as another user, you specify the user in the
<code class="literal">es-security-runas-user</code> request header. For example:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">curl -H "es-security-runas-user: jacknich"  -u es_admin -XGET 'http://localhost:9200/'</pre>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="field-and-document-access-control.html">« Setting up field and document level security</a>
</span>
<span class="next">
<a href="configuring-authorization-delegation.html">Configuring authorization delegation »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>